﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RaisingStudio.Data.Common;

namespace PerformanceTest
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            Dictionary<string, int> dic = new Dictionary<string, int>();
            int count = 1000000;
            for (int i = 0; i < count; i++)
            {
                dic.Add(i.ToString(), i);
            }
            for (int i = 0; i < count; i++)
            {
                int value;
                if(dic.TryGetValue(i.ToString(), out value));
            }
            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds.ToString());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            CommonDictionary dic = new CommonDictionary();
            int count = 1000000;
            for (int i = 0; i < count; i++)
            {
                dic.Add(i.ToString(), i);
            }
            for (int i = 0; i < count; i++)
            {
                int value;
                if(dic.TryGetValue(i.ToString(), out value));
            }
            sw.Stop();
            MessageBox.Show(sw.ElapsedMilliseconds.ToString());
        }
    }
}
